<template>
			<!-- 隐私保护指引弹窗 -->
			<uni-popup ref="privacyShow" mode="center" width="600rpx" border-radius="20" :mask-close-able="false">
				<view class="privacyBox">
					<view class="privacyTit">用户隐私保护提示</view>
					<view class="privacyDesc">
						感谢您的使用，在使用本小程序前，应当阅读并同意<text style="color: #409EFE;"
							@click="openPrivacyContract">《用户隐私保护指引》</text>。当您点击同意并开始使用程序服务时，即表示您已理解并同意该条款内容，该条款将对您产生法律约束力。如您拒绝，将无法进入小程序。
					</view>
					<view class="privacyPost">
						<view class="refuseBtn">
							<navigator target="miniProgram" open-type="exit" @click="exit">不同意并退出</navigator>
						</view>
						<button class="agreeBtn" open-type="agreePrivacyAuthorization"
							@agreeprivacyauthorization="agreeClick">同意并继续</button>
					</view>
				</view> 
			</uni-popup>
</template>

<script>
import func from '@/utils/funlogin.js';
import { getDriving } from '@/api/me.js';
import { getPhone, getTenentList, wxPhoneLogin,getTenantsByOpenId,getPhoneByOpenid } from '@/api/login.js';
import { setTenantId, getTenantId,setToken,removeTenantId} from '@/utils/auth.js';
import { toast } from '../utils/common';

export default {
	name: 'agreement',
	data() {
		return {
			
		};
	},
	onReady() {
		var _this = this;
		// 隐私政策
		_this.$refs['privacyShow'].open();
		wx.getPrivacySetting({
			success: res => {
				// 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
				console.log(res,'返回来的===')
				if (!res.needAuthorization) {
					// 需要弹出隐私协议
					console.log('未同意')
					return;
				} else {
					// 用户已经同意过隐私协议，所以不需要再弹出隐私协议，也能调用隐私接口
					// _this.agree = 1
					// _this.checkedFlag = true
				}
			},
			fail: () => {},
			complete:() => {}
		})
	},
	methods: {
		openPrivacyContract() {
		  wx.openPrivacyContract({
			success: res => {
			  console.log('openPrivacyContract success')
			},
			fail: res => {
			  console.error('openPrivacyContract fail', res)
			}
		  })
		},
		OpenAgreeClick(){
			this.$refs['privacyShow'].open();
		},
		// 同意
		agreeClick() {
			// 用户点击了同意，之后所有已声明过的隐私接口和组件都可以调用了
			
			this.$refs['privacyShow'].close();
			// 重新授权定位，调取父组件方法
			// this.$parent.getLocation();
		}
	}
};
</script>

<style scoped lang="scss">
	.privacyBox {
		padding: 60rpx;
		box-sizing: border-box;
		
	}
 
	.privacyTit {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
		text-align: center;
		overflow: hidden;
	}
 
	.privacyDesc {
		font-size: 28rpx;
		color: #333;
		overflow: hidden;
		margin-top: 30rpx;
	}
 
	.privacyDesc text {
		color: #333;
	}
 
	.privacyPost {
		overflow: hidden;
		margin-top: 60rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
 
	.privacyPost .refuseBtn {
		flex: 1;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		font-size: 28rpx;
		font-weight: bold;
		color: #fff;
		background: #333;
		border-radius: 40rpx;
		box-sizing: border-box;
		overflow: hidden;
	}
 
	.privacyPost .agreeBtn {
		flex: 1;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		font-size: 28rpx;
		font-weight: bold;
		color: #fff;
		background: blue;
		border-radius: 40rpx;
		box-sizing: border-box;
		overflow: hidden;
		margin-left: 20rpx;
	}
</style>